#include <boost/test/unit_test.hpp>
#include <qua/fixed.h>
#include <qua/text.h>
#include <qua/cast.h>
#include <qua/io.h>

using namespace qua;

struct fixed_test_fixture
{
    fixed_test_fixture()
    {
    }

    ~fixed_test_fixture()
    {
    }
};

BOOST_FIXTURE_TEST_SUITE( fixed_test_suite, fixed_test_fixture )

BOOST_AUTO_TEST_CASE( fixed_simple_test_case )
{
    fixed a;
    BOOST_CHECK( !a.floor() );
    BOOST_CHECK( !a.mulfrac() );
    BOOST_CHECK_EQUAL( static_cast<double>(a), 0 );
    BOOST_CHECK_EQUAL( cast<text>(a), text("0") );

    fixed b = -1;
    BOOST_CHECK_EQUAL( b.floor(), -1 );
    BOOST_CHECK( !b.mulfrac() );

    fixed c = 3;
    BOOST_CHECK_NE( b, c );

    a = b/c;
    BOOST_CHECK_EQUAL( a.floor(), -1LL );
    BOOST_CHECK_EQUAL( a.mulfrac(), 666666666666666667uLL );

    b = a*c;
    BOOST_CHECK_EQUAL( b.floor(), -1 );
    BOOST_CHECK_EQUAL( b.frac(), 0 );
}

BOOST_AUTO_TEST_SUITE_END()
